using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework;

namespace Andrewl.XnaHelpers
{
    public static class Helpers
    {
        public static DisplayMode DisplayMode
        { get { return XnaHelpers.graphicsDevice.DisplayMode; } }

        public static Rectangle SafeArea
        { get { return XnaHelpers.graphicsDevice.Viewport.TitleSafeArea; } }

        public static int RefreshRate
        { get { return XnaHelpers.graphicsDevice.DisplayMode.RefreshRate; } }

        public static Point Resolution
        { get { return new Point(XnaHelpers.graphicsDevice.DisplayMode.Width, XnaHelpers.graphicsDevice.DisplayMode.Height); } }

        public static Vector2 CalculateOrigin(float x, float y)
        {
            return new Vector2(x / 2, y / 2);
        }

        public static Vector2 CalculateOrigin(ref Texture2D sprite)
        {
            return new Vector2(sprite.Width / 2, sprite.Height / 2);
        }

        public static Vector2 CalculateOrigin(ref Rectangle rect)
        {
            return new Vector2(rect.Width / 2, rect.Height / 2);
        }

        public static void DrawSprite(ref Texture2D tex, Vector2 position)
        {
            XnaHelpers.SpriteBatch.Draw(tex, position, Color.White);
        }

        public static void DrawRectangle(ref Rectangle rect, Color color)
        {
            XnaHelpers.SpriteBatch.Draw(XnaHelpers.WhitePixel, rect, color);
        }

        public static void SetResolution(GraphicsDeviceManager deviceManager, Point Resolution, bool MultiSampling)
        {
            deviceManager.PreferredBackBufferWidth = Resolution.X;
            deviceManager.PreferredBackBufferHeight = Resolution.Y;
            deviceManager.PreferMultiSampling = MultiSampling;
        }

    }
}